package com.wlz.security.config;

import com.wlz.security.service.MyUserDetailsService2;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 *  方式 3 基于UserDetailsService接口
 */
//@Configuration
//@EnableWebSecurity 基于springboot 可以不用
public class WebSecurityConfig2 extends WebSecurityConfigurerAdapter {


    @Bean
    public PasswordEncoder passwordEncoder(){
        //return NoOpPasswordEncoder.getInstance();
        return new BCryptPasswordEncoder();
    }

    @Bean
    public UserDetailsService userDetailsServiceBean() {
        return new MyUserDetailsService2();
    }

}
